<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
    <link href="/Public/Admin/css/new_plan.css" rel="stylesheet" />
    <script src="/Public/static/layer/layer.js"></script>
    <!--文件上传-->
    <script type="text/javascript" src="/Public/Cropper/js/ajaxfileupload.js" ></script>
    <style>
        .textarea{height:50px;width:90%}
        .checkCont p{float:left;}
        .checkCont a{margin-left:10px;display: inline-block;}
        .fujian{margin:0;}
        .c-red{color:red}
        .pointer{cursor: pointer}
        .radioBox{padding:8px 0;}
        .radioBox>lable{margin-right:12px;}
        .radioBox>lable>i{position: relative;top: 2px}
        .planSaveBtn{border: 1px solid  #2299ee;color: #2299ee;background:#fff;}
        .planSaveBtn:hover{color: #2299ee;}
        .btnMargin .layui-btn{margin-right:10px;}
    </style>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Plan/index')}">返回</a>
                    </div>
                    <input type="hidden" id="pType" value="{$params.pType}" />
                    <input type="hidden" id="deptName" value="{$params.deptName}" />
                    <input type="hidden" id="level" value="{$params.level}" />
                    <input type="hidden" id="smsFlag" value="{$params.smsFlag}" />
                    <input type="hidden" id="planName" value="{$params.planName}" />
                    <input type="hidden" id="start" value="{$params.start}" />
                    <input type="hidden" id="end" value="{$params.end}" />
                    <input type="hidden" id="p" value="{$params.p}" />
                </blockquote>
                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">流程分类</label>
                        <div class="layui-input-block">
                            <select name="type" class="layui-input" lay-verify="required">
                                <foreach name="planType" item="type">
                                    <option value="{$type.type_id}" {$info['type'] == $type['type_id'] ? 'selected' : ''}>{$type.type_name}</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                    <if condition="$info['child_type'] neq null">
                        <div class="layui-form-item">
                            <label class="layui-form-label">标记</label>
                            <div class="layui-input-block">
                                <input type="text" autocomplete="off" class="layui-input" value="{$info.child_type|getChildType}" readonly />
                            </div>
                        </div>
                    </if>
                    <div class="layui-form-item point">
                        <a class="open">
                            <label class="layui-form-label pointer" style="width:200px;text-align: right;padding-right:0">展开标记</label>
                            <img src="/Public/Admin/images/arrow-down.png" style="margin-top: 10px;">
                        </a>
                    </div>
                    <div class="childCate" style="display:none">
                        <div class="layui-form-item">
                            <label class="layui-form-label">选择标记</label>
                            <div class="layui-input-block">
                                <select name="child_type" class="layui-input">
                                    <option value="0">请选择</option>
                                    <foreach name="planFlag" item="pflag">
                                        <option value="{$pflag.type_id}">{$pflag.type_name}</option>
                                    </foreach>s
                                </select>
                            </div>
                            <input type="hidden" class="getChildType" value="{:U('getChildType')}">
                            <input type='hidden' class="currType" value="{$info.child_type|default=0}">
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">增加标记</label>
                            <div class="layui-input-block">
                                <input type="text" name="add_type" autocomplete="off" class="layui-input" value="" />
                            </div>
                        </div>
                    </div>

                    <!--简洁模式-->
                    <div class="simple">
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label"><span class="c-red">*</span>任务</label>
                            <div class="layui-input-block">
                                <textarea name="cont" placeholder="请输入内容" class="layui-textarea cont">{$info.content}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label"><span class="c-red">*</span>执行人</label>
                            <div class="layui-input-block layui-input checkCont value executor" style="width:90%">
                                <p class="textarea addUser addUser_5" data-id="5" data-key="executor">
                                    <span></span>
                                <foreach name="info.execs" item="exec">
                                    <span class="one-name">
                                        <a>{$exec|getChineseName}</a>
                                        <img class="pointer delOperator" data-id="{$exec}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                        <input type="hidden" name="executor[]" value="{$exec}">
                                        <input type="hidden" name="user_names[]" value="{$exec|getChineseName}">
                                    </span>
                                </foreach>
                                </p>
                                <!--<a class="arrow pointer addUser addUser_5" data-id="5" data-key="executor">&#xe638;</a>-->
                                <!--<a class="pointer delData">清空</a>-->
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>计划级别</label>
                            <div class="layui-input-block level radioBox">
                                <lable class="input_lable">
                                    <i class='input_style radio_bg <if condition="$info[level] eq 2">radio_bg_check</if>'><input type="radio" name="s_level" value="2" {$info['level'] == 2 ? 'checked' : ''}></i>
                                    部门级
                                </lable>
                                <lable class="input_lable">
                                    <i class='input_style radio_bg <if condition="$info[level] eq 1">radio_bg_check</if>'><input type="radio" name="s_level" value="1" {$info['level'] == 1 ? 'checked' : ''}></i>
                                    个人级
                                </lable>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">汇报周期</label>
                            <div class="layui-input-block">
                                <select name="s_cycle" class="layui-input">
                                    <option value="1">一周一报</option>
                                    <option value="2">一周二报</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">标的物</label>
                            <if condition="$id neq null">
                                <div class="layui-input-block">
                                    <div class="fujian">
                                        <i class="iconfont">&#xe88a;</i> 
                                        <a href="#"><span class="fj">上传标的物({$info.attach_type|getAttchType})</span>
                                            <span class="icon_add" id="upload">&#xe638;</span>
                                        </a>
                                        <div class="filename-cont">
                                            <foreach name="uploads" item="upload">
                                                <if condition="$upload['is_pic'] eq 0">
                                                    <p style="border:0;line-height: 2em">
                                                        <a href="{$upload.url}" download="{$upload.name}">{$upload.name}</a><img src="/Public/Index/img/close.png" style="width:15px" class="pointer delfile" data-fileurl="{$upload.url}">;
                                                    </p>
                                                    <else/>
                                                    <img class="showImg" src="{$upload.url}" width="100px" style="margin-right:10px" /><img src="/Public/Index/img/close.png" style="width:15px" class="pointer delfile" data-fileurl="{$upload.url}">;
                                                </if>
                                            </foreach>
                                        </div>
                                    </div>
                                </div>
                                <else />
                                <div class="layui-input-block attach_type radioBox">
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 1">radio_bg_check</if>'><input type="radio" name="s_attach_type" value="1" {$info['attach_type'] == 1 ? 'checked' : ''}></i>
                                        word
                                    </lable>
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 2">radio_bg_check</if>'><input type="radio" name="s_attach_type" value="2" {$info['attach_type'] == 2 ? 'checked' : ''}></i>
                                        excel
                                    </lable>
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 3">radio_bg_check</if>'><input type="radio" name="s_attach_type" value="3" {$info['attach_type'] == 3 ? 'checked' : ''}></i>
                                        ppt
                                    </lable>
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 4">radio_bg_check</if>'><input type="radio" name="s_attach_type" value="4" {$info['attach_type'] == 4 ? 'checked' : ''}></i>
                                        code
                                    </lable>
                                    <div style="clear:both"></div>
                                </div>
                            </if>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>紧急程度</label>
                            <div class="layui-input-block flag radioBox">
                                <lable class="input_lable" style="color:#235AA3">
                                    <i class='input_style radio_bg <if condition="$info[flag] eq 3">radio_bg_check</if>'><input type="radio" name="flag" value="3" {$info['flag'] == 3 ? 'checked' : ''}></i>
                                    一般
                                </lable>
                                <lable class="input_lable" style="color:#EA6900">
                                    <i class='input_style radio_bg <if condition="$info[flag] eq 2">radio_bg_check</if>'><input type="radio" name="flag" value="2" {$info['flag'] == 2 ? 'checked' : ''}></i>
                                    重要
                                </lable>
                                <lable class="input_lable" style="color:#E43127">
                                    <i class='input_style radio_bg <if condition="$info[flag] eq 1">radio_bg_check</if>'><input type="radio" name="flag" value="1" {$info['flag'] == 1 ? 'checked' : ''}></i>
                                    紧急
                                </lable>
                                <div style="clear:both"></div>
                            </div>
                        </div>
                    </div>

                    <!--详细模式-->
                    <div class="complex" style='display: none'>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>计划名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" required lay-verify="required" autocomplete="off" class="layui-input" value="{$info.name}" />
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">开放部门</label>
                            <div class="layui-input-block layui-input checkCont" style="width:90%">
                                <p class="textarea depart addDept">
                                    <span></span>
                                <foreach name="info.depts" item="dept">
                                    <span>
                                        <a>{$dept|getDeptName}</a>
                                        <img class="pointer delOperator" data-id="{$dept}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                        <input type="hidden" name="dept_ids[]" value="{$dept}">
                                        <input type="hidden" name="dept_names[]" value="{$dept|getDeptName}">
                                    </span>
                                </foreach>
                                </p>
                                <!--<a class="arrow pointer addDept">&#xe638;</a>-->
                                <!--<a class="pointer delData">清空</a>-->
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">开放人员</label>
                            <div class="layui-input-block layui-input checkCont value" style="width:90%">
                                <p class="textarea addUser addUser_1" data-id="1" data-key="to_person_id">
                                    <span></span>
                                <foreach name="info.persons" item="person">
                                    <span class="one-name">
                                        <a>{$person|getChineseName}</a>
                                        <img class="pointer delOperator" data-id="{$person}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                        <input type="hidden" name="to_person_id[]" value="{$person}">
                                        <input type="hidden" name="user_names[]" value="{$person|getChineseName}">
                                    </span>
                                </foreach>
                                </p>
                                <!--<a class="arrow pointer addUser addUser_1" data-id="1" data-key="to_person_id">&#xe638;</a>-->
                                <!--<a class="pointer delData">清空</a>-->
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">参与人</label>
                            <div class="layui-input-block layui-input checkCont value" style="width:90%">
                                <p class="textarea addUser addUser_2" data-id="2" data-key="participator">
                                    <span></span>
                                <foreach name="info.parts" item="part">
                                    <span class="one-name">
                                        <a>{$part|getChineseName}</a>
                                        <img class="pointer delOperator" data-id="{$part}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                        <input type="hidden" name="participator[]" value="{$part}">
                                        <input type="hidden" name="user_names[]" value="{$part|getChineseName}">
                                    </span>
                                </foreach>
                                </p>
                                <!--<a class="arrow pointer addUser addUser_2" data-id="2" data-key="participator">&#xe638;</a>-->
                                <!--<a class="pointer delData">清空</a>-->
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label"><span class="c-red">*</span>负责人</label>
                            <div class="layui-input-block layui-input checkCont value manager" style="width:90%">
                                <p class="textarea addUser addUser_3" data-id="3" data-key="manager">
                                    <span></span>
                                <if condition="$info[manager] neq null">
                                    <foreach name="info.manager" item="manager">
                                        <span class="one-name">
                                            <a>{$manager|getChineseName}</a>
                                            <img class="pointer delOperator" data-id="{$manager}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                            <input type="hidden" name="manager[]" value="{$manager}">
                                            <input type="hidden" name="user_names[]" value="{$manager|getChineseName}">
                                        </span>
                                    </foreach>
                                </if>
                                </p>
                                <!--<a class="arrow pointer addUser addUser_3" data-id="3" data-key="manager">&#xe638;</a>-->
                                <!--<a class="pointer delData">清空</a>-->
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">批注领导</label>
                            <div class="layui-input-block layui-input checkCont value" style="width:90%">
                                <p class="textarea addUser addUser_4" data-id="4" data-key="opinion_leader">
                                    <span></span>
                                <foreach name="info.leaders" item="leader">
                                    <span class="one-name">
                                        <a>{$leader|getChineseName}</a>
                                        <img class="pointer delOperator" data-id="{$leader}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                        <input type="hidden" name="executor[]" value="{$leader}">
                                        <input type="hidden" name="user_names[]" value="{$leader|getChineseName}">
                                    </span>
                                </foreach>
                                </p>
                                <!--<a class="arrow pointer addUser addUser_4" data-id="4" data-key="opinion_leader">&#xe638;</a>-->
                                <!--<a class="pointer delData">清空</a>-->
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>计划级别</label>
                            <div class="layui-input-block level">
                                <lable class="input_lable">
                                    <i class='input_style radio_bg <if condition="$info[level] eq 2">radio_bg_check</if>'><input type="radio" name="level" value="2" {$info['level'] == 2 ? 'checked' : ''}></i>
                                    部门级
                                </lable>
                                <lable class="input_lable">
                                    <i class='input_style radio_bg <if condition="$info[level] eq 1">radio_bg_check</if>'><input type="radio" name="level" value="1" {$info['level'] == 1 ? 'checked' : ''}></i>
                                    个人级
                                </lable>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-block">
                                <textarea name="remark" placeholder="请输入内容" class="layui-textarea">{$info.remark}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>开始时间</label>
                            <div class="layui-input-block">
                                <input type="text" name="begin_date" required lay-verify="required" autocomplete="off" placeholder="点击打开日历" class="layui-input datepickerInput" value="{$info.begin_date}" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">结束时间</label>
                            <div class="layui-input-block">
                                <input type="text" name="end_date" autocomplete="off" placeholder="点击打开日历" class="layui-input datepickerInput" value="{$info.end_date}" />
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">计划内容</label>
                            <div class="layui-input-block">
                                <textarea name="content" placeholder="请输入内容" class="layui-textarea">{$info.content}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">汇报周期</label>
                            <div class="layui-input-block">
                                <select name="cycle" class="layui-input">
                                    <option value="1">一周一报</option>
                                    <option value="2">一周二报</option>
                                    <option value="3">一月一报</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">标的物</label>
                            <if condition="$id neq null">
                                <div class="layui-input-block">
                                    <div class="fujian">
                                        <i class="iconfont">&#xe88a;</i> 
                                        <a href="#"><span class="fj">上传标的物({$info.attach_type|getAttchType})</span>
                                            <span class="icon_add" id="upload">&#xe638;</span>
                                        </a>
                                        <div class="filename-cont">
                                            <foreach name="uploads" item="upload">
                                                <if condition="$upload['is_pic'] eq 0">
                                                    <p style="border:0;line-height: 2em">
                                                        <a href="{$upload.url}" download="{$upload.name}">{$upload.name}</a><img src="/Public/Index/img/close.png" style="width:15px" class="pointer delfile" data-fileurl="{$upload.url}">;
                                                    </p>
                                                    <else/>
                                                    <img class="showImg" src="{$upload.url}" width="100px" style="margin-right:10px" /><img src="/Public/Index/img/close.png" style="width:15px" class="pointer delfile" data-fileurl="{$upload.url}">;
                                                </if>
                                                <!--<span>{$upload.name}<img src="/Public/Index/img/close.png" style="width:15px" class="pointer delfile" data-fileurl="{$upload.url}">; </span>-->
                                            </foreach>
                                        </div>
                                    </div>
                                </div>
                                <else />
                                <div class="layui-input-block attach_type">
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 1">radio_bg_check</if>'><input type="radio" name="attach_type" value="1" {$info['attach_type'] == 1 ? 'checked' : ''}></i>
                                        word
                                    </lable>
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 2">radio_bg_check</if>'><input type="radio" name="attach_type" value="2" {$info['attach_type'] == 2 ? 'checked' : ''}></i>
                                        excel
                                    </lable>
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 3">radio_bg_check</if>'><input type="radio" name="attach_type" value="3" {$info['attach_type'] == 3 ? 'checked' : ''}></i>
                                        ppt
                                    </lable>
                                    <lable class="input_lable">
                                        <i class='input_style radio_bg <if condition="$info[attach_type] eq 4">radio_bg_check</if>'><input type="radio" name="attach_type" value="4" {$info['attach_type'] == 4 ? 'checked' : ''}></i>
                                        code
                                    </lable>
                                    <div style="clear:both"></div>
                                </div>
                            </if>
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <div class="layui-input-block btnMargin">
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('save')}" data-form="">提交</a>
                            <a class="layui-btn btn-submit ajax-post planSaveBtn" data-url="{:U('save',array('type'=>1))}" data-form="">保存</a>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>


                    <input type="file" id="inputImage" name='imgfile' style="display:none">
                    <input type="hidden" id="filename" name="uploads" value="{$uploads[0].uploadsName}">
                    <input type="hidden" id="fileurl" name="uploads_url" value="{$uploads[0].uploadsUrl}">
                    <input type="hidden" name="url" value="{:U('delFile',array('table'=>'work_plan','field'=>'plan_id','id'=>$info['plan_id']))}">
                    <input type='hidden' name='plan_id' value='{$info.plan_id}'>
                </form>
            </div>
        </div>

    </section>
</block>
<block name="script">
    <script type="text/javascript" src="/Public/Admin/js/plan.js"></script>
    <script type="text/javascript">
        //检查表单
        $('.ajax-post').on('click', function () {
            var flag = true;
            if ($('select[name=type]').val() == 1) {
                //日计划
                if ($('.cont').val() == '') {
                    layer.msg('任务内容不能为空!');
                    flag = false;
                }

                if ($('.executor .textarea span').text() == '') {
                    layer.msg('请选择执行人!');
                    flag = false;
                }

                var check = false;
                $('.flag').find('input[name=flag]').each(function () {
                    if ($(this).attr('checked') == 'checked') {
                        check = true;
                    }
                })
                if (check == false) {
                    layer.msg('请选择紧急程度!');
                    flag = false;
                }
                var check = false;
                $('.level').find('input[name=s_level]').each(function () {
                    if ($(this).attr('checked') == 'checked') {
                        check = true;
                    }
                })
                if (check == false) {
                    layer.msg('请选择计划级别!');
                    flag = false;
                }

            } else {
                //详细计划
                if ($('input[name=name]').val() == '') {
                    layer.msg('计划名称不能为空!');
                    flag = false;
                }

                if ($('.manager .textarea span').text() == '') {
                    layer.msg('请选择负责人!');
                    flag = false;
                }

                var check = false;
                $('.level').find('input[name=level]').each(function () {
                    if ($(this).attr('checked') == 'checked') {
                        check = true;
                    }
                })
                if (check == false) {
                    layer.msg('请选择计划级别!');
                    flag = false;
                }

                if ($('input[name=begin_date]').val() == '') {
                    layer.msg('开始时间不能为空!');
                    flag = false;
                }
            }

            if (flag == false) {
                $(this).removeClass('btn-submit');
            } else {
                $(this).addClass('btn-submit');
            }
        })

        $(initAddPlan());
        
        $(function () {
            if ($('select[name=type]').find('option:selected').val() == 1) {
                $('.complex').hide();
                $('.simple').show();
            } else {
                $('.complex').show();
                $('.simple').hide();
            }
        })

    </script>    
    <script type="text/javascript" src="/Public/Admin/js/common.js" ></script>
    <script>
        $(dateTime(0));
        $(initUpload("{:U(CONTROLLER_NAME.'/upload')}"));
    </script>
</block>
